//
//  TaskManagerListCell.m
//  LogisticsSupplier
//
//  Created by 吕晶 on 2021/3/19.
//  Copyright © 2021 吕晶. All rights reserved.
//

#import "TaskManagerListCell.h"

@interface TaskManagerListCell ()

@property (nonatomic, strong) UIView *bgView;
@property (nonatomic, strong) UILabel *noTitleLab;//提单号
@property (nonatomic, strong) UILabel *noLab;
@property (nonatomic, strong) UILabel *laiYuanLab;//我方确认

@property (nonatomic, strong) UIView *addressBGView;
@property (nonatomic, strong) UIImageView *tiImgView;
@property (nonatomic, strong) UILabel *tiAddressLab;
@property (nonatomic, strong) UIImageView *songImgView;
@property (nonatomic, strong) UILabel *songAddressLab;
@property (nonatomic, strong) UILabel *linkLine;
@property (nonatomic, strong) UILabel *marginLine1;

@property (nonatomic, strong) UILabel *taskTitleLab;
@property (nonatomic, strong) UILabel *taskLab;
@property (nonatomic, strong) UILabel *carTitleLab;
@property (nonatomic, strong) UILabel *carLab;
@property (nonatomic, strong) UILabel *jnumTitleLab;
@property (nonatomic, strong) UILabel *jnumLab;
@property (nonatomic, strong) UILabel *countTitleLab;
@property (nonatomic, strong) UILabel *countLab;
@property (nonatomic, strong) UILabel *weightTitleLab;
@property (nonatomic, strong) UILabel *weightLab;
@property (nonatomic, strong) UILabel *volumeTitleLab;
@property (nonatomic, strong) UILabel *volumeLab;
@property (nonatomic, strong) UILabel *timeTitleLab;
@property (nonatomic, strong) UILabel *timeLab;

@property (nonatomic, strong) UILabel *price1TitleLab;
@property (nonatomic, strong) UILabel *price1Lab;
@property (nonatomic, strong) UILabel *price1UnitLab;
@property (nonatomic, strong) UILabel *descLab;

@property (nonatomic, strong) UIButton *boHuiBtn;//驳回
@property (nonatomic, strong) UIButton *sureBtn;//确认
@property (nonatomic, strong) UIButton *diaoDuBtn;//调度
@property (nonatomic, strong) UIButton *shouHuoBtn;//收货
@property (nonatomic, strong) UIButton *chuFaBtn;//出发
@property (nonatomic, strong) UIButton *yiChangShangBaoBtn;//异常上报
@property (nonatomic, strong) UIButton *daoDaBtn;//到达
@property (nonatomic, strong) UIButton *zhuangCheBtn;//装车
@property (nonatomic, strong) UIButton *songHuoChuFaBtn;//送货出发
@property (nonatomic, strong) UIButton *erWeiMaBtn;//二维码
@property (nonatomic, strong) UIButton *guiJiBtn;//轨迹
@property (nonatomic, strong) UIButton *huiDanFanHuiBtn;//回单返回
@property (nonatomic, strong) UIButton *boHuiReasonBtn;//驳回原因

@end

@implementation TaskManagerListCell

+ (instancetype)TaskManagerListCellWithTableView:(UITableView *)tableView {
    static NSString *cellID = @"TaskManagerListCell";
    TaskManagerListCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
    if (cell == nil) {
        cell = [[TaskManagerListCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID];
    }
    return cell;
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        self.backgroundColor = Color_backgroundColor;
        self.bgView = [UIView new];
        self.bgView.backgroundColor = HexColor(0xffffff);
        self.bgView.layer.masksToBounds = YES;
        self.bgView.layer.cornerRadius = 6;
        [self.contentView addSubview:self.bgView];
        
        self.noTitleLab = [UILabel new];
        self.noTitleLab.textColor = HexColor(0x9C9DB3);
        self.noTitleLab.font = [UIFont systemFontOfSize:12];
        [self.bgView addSubview:self.noTitleLab];
        
        self.noLab = [UILabel new];
        self.noLab.textColor = HexColor(0x2B2C44);
        self.noLab.font = BoldFontOfSize(12);
        [self.bgView addSubview:self.noLab];
        
        self.laiYuanLab = [UILabel new];
        self.laiYuanLab.font = BoldFontOfSize(14);
        self.laiYuanLab.textColor = Color_ThemeColor;
        [self.bgView addSubview:self.laiYuanLab];
        
        self.addressBGView = [UIView new];
        self.addressBGView.backgroundColor = HexColor(0xF7F7FA);
        [self.bgView addSubview:self.addressBGView];
        
        self.tiImgView = [UIImageView new];
        [self.addressBGView addSubview:self.tiImgView];
        
        self.tiAddressLab = [UILabel new];
        self.tiAddressLab.textColor = HexColor(0x2B2C44);
        self.tiAddressLab.font = BoldFontOfSize(14);
        [self.addressBGView addSubview:self.tiAddressLab];
        
        self.songImgView = [UIImageView new];
        [self.addressBGView addSubview:self.songImgView];
        
        self.songAddressLab = [UILabel new];
        self.songAddressLab.textColor = HexColor(0x2B2C44);
        self.songAddressLab.font = BoldFontOfSize(14);
        [self.addressBGView addSubview:self.songAddressLab];
        
        self.linkLine = [UILabel new];
        self.linkLine.backgroundColor = HexColorA(0x3D68EB, 0.1);
        [self.addressBGView addSubview:self.linkLine];
        
        self.marginLine1 = [UILabel new];
        self.marginLine1.backgroundColor = HexColor(0xF2F2F5);
        [self.addressBGView addSubview:self.marginLine1];
        
        self.taskTitleLab = [UILabel new];
        self.taskTitleLab.textColor = HexColor(0x9C9DB3);
        self.taskTitleLab.font = [UIFont systemFontOfSize:14];
        [self.bgView addSubview:self.taskTitleLab];
        
        self.taskLab = [UILabel new];
        self.taskLab.textColor = HexColor(0x2B2C44);
        self.taskLab.font = [UIFont systemFontOfSize:14];
        [self.bgView addSubview:self.taskLab];
        
        self.carTitleLab = [UILabel new];
        self.carTitleLab.textColor = HexColor(0x9C9DB3);
        self.carTitleLab.font = [UIFont systemFontOfSize:14];
        [self.bgView addSubview:self.carTitleLab];
        
        self.carLab = [UILabel new];
        self.carLab.textColor = HexColor(0x2B2C44);
        self.carLab.font = [UIFont systemFontOfSize:14];
        [self.bgView addSubview:self.carLab];
        
        self.jnumTitleLab = [UILabel new];
        self.jnumTitleLab.textColor = HexColor(0x9C9DB3);
        self.jnumTitleLab.font = [UIFont systemFontOfSize:14];
        [self.bgView addSubview:self.jnumTitleLab];
        
        self.jnumLab = [UILabel new];
        self.jnumLab.textColor = HexColor(0x2B2C44);
        self.jnumLab.font = [UIFont systemFontOfSize:14];
        [self.bgView addSubview:self.jnumLab];
        
        self.countTitleLab = [UILabel new];
        self.countTitleLab.textColor = HexColor(0x9C9DB3);
        self.countTitleLab.font = [UIFont systemFontOfSize:14];
        [self.bgView addSubview:self.countTitleLab];
        
        self.countLab = [UILabel new];
        self.countLab.textColor = HexColor(0x2B2C44);
        self.countLab.font = [UIFont systemFontOfSize:14];
        [self.bgView addSubview:self.countLab];
        
        self.weightTitleLab = [UILabel new];
        self.weightTitleLab.textColor = HexColor(0x9C9DB3);
        self.weightTitleLab.font = [UIFont systemFontOfSize:14];
        [self.bgView addSubview:self.weightTitleLab];
        
        self.weightLab = [UILabel new];
        self.weightLab.textColor = HexColor(0x2B2C44);
        self.weightLab.font = [UIFont systemFontOfSize:14];
        [self.bgView addSubview:self.weightLab];
        
        self.volumeTitleLab = [UILabel new];
        self.volumeTitleLab.textColor = HexColor(0x9C9DB3);
        self.volumeTitleLab.font = [UIFont systemFontOfSize:14];
        [self.bgView addSubview:self.volumeTitleLab];
        
        self.volumeLab = [UILabel new];
        self.volumeLab.textColor = HexColor(0x2B2C44);
        self.volumeLab.font = [UIFont systemFontOfSize:14];
        [self.bgView addSubview:self.volumeLab];
        
        self.timeTitleLab = [UILabel new];
        self.timeTitleLab.textColor = HexColor(0x9C9DB3);
        self.timeTitleLab.font = [UIFont systemFontOfSize:14];
        [self.bgView addSubview:self.timeTitleLab];
        
        self.timeLab = [UILabel new];
        self.timeLab.textColor = HexColor(0x2B2C44);
        self.timeLab.font = [UIFont systemFontOfSize:14];
        [self.bgView addSubview:self.timeLab];
        
        self.price1TitleLab = [UILabel new];
        self.price1TitleLab.textColor = HexColor(0x585974);
        self.price1TitleLab.font = BoldFontOfSize(14);
        [self.bgView addSubview:self.price1TitleLab];
        
        self.price1Lab = [UILabel new];
        self.price1Lab.textColor = HexColor(0xF35959);
        self.price1Lab.font = BoldFontOfSize(20);
        [self.bgView addSubview:self.price1Lab];
        
        self.price1UnitLab = [UILabel new];
        self.price1UnitLab.textColor = HexColor(0x9C9DB3);
        self.price1UnitLab.font = [UIFont systemFontOfSize:14];
        [self.bgView addSubview:self.price1UnitLab];
        
        self.descLab = [UILabel new];
        self.descLab.textColor = HexColor(0x9C9DB3);
        self.descLab.font = [UIFont systemFontOfSize:10];
        [self.bgView addSubview:self.descLab];
        
        self.sureBtn = [UIButton new];
        [self.sureBtn setTitle:@"确认" forState:0];
        [self.sureBtn setTitleColor:HexColor(0xffffff) forState:0];
        self.sureBtn.titleLabel.font = BoldFontOfSize(14);
        self.sureBtn.layer.masksToBounds = YES;
        self.sureBtn.layer.cornerRadius = 16;
        self.sureBtn.backgroundColor = Color_ThemeColor;
        [self.sureBtn addTarget:self action:@selector(sureClick) forControlEvents:UIControlEventTouchUpInside];
        [self.bgView addSubview:self.sureBtn];
        
        self.boHuiBtn = [UIButton new];
        [self.boHuiBtn setTitle:@"驳回" forState:0];
        [self.boHuiBtn setTitleColor:HexColor(0xffffff) forState:0];
        self.boHuiBtn.titleLabel.font = BoldFontOfSize(14);
        self.boHuiBtn.layer.masksToBounds = YES;
        self.boHuiBtn.layer.cornerRadius = 16;
        self.boHuiBtn.backgroundColor = HexColor(0xF35959);
        [self.boHuiBtn addTarget:self action:@selector(boHuiClick) forControlEvents:UIControlEventTouchUpInside];
        [self.bgView addSubview:self.boHuiBtn];
        
        self.diaoDuBtn = [UIButton new];
        [self.diaoDuBtn setTitle:@"调度" forState:0];
        [self.diaoDuBtn setTitleColor:HexColor(0xffffff) forState:0];
        self.diaoDuBtn.titleLabel.font = BoldFontOfSize(14);
        self.diaoDuBtn.layer.masksToBounds = YES;
        self.diaoDuBtn.layer.cornerRadius = 16;
        self.diaoDuBtn.backgroundColor = Color_ThemeColor;
        [self.diaoDuBtn addTarget:self action:@selector(diaoDuClick) forControlEvents:UIControlEventTouchUpInside];
        [self.bgView addSubview:self.diaoDuBtn];
        
        self.shouHuoBtn = [UIButton new];
        [self.shouHuoBtn setTitle:@"收货" forState:0];
        [self.shouHuoBtn setTitleColor:HexColor(0xffffff) forState:0];
        self.shouHuoBtn.titleLabel.font = BoldFontOfSize(14);
        self.shouHuoBtn.layer.masksToBounds = YES;
        self.shouHuoBtn.layer.cornerRadius = 16;
        self.shouHuoBtn.backgroundColor = Color_ThemeColor;
        [self.shouHuoBtn addTarget:self action:@selector(shouHuoClick) forControlEvents:UIControlEventTouchUpInside];
        [self.bgView addSubview:self.shouHuoBtn];
        
        self.chuFaBtn = [UIButton new];
        [self.chuFaBtn setTitle:@"出发" forState:0];
        [self.chuFaBtn setTitleColor:HexColor(0xffffff) forState:0];
        self.chuFaBtn.titleLabel.font = BoldFontOfSize(14);
        self.chuFaBtn.layer.masksToBounds = YES;
        self.chuFaBtn.layer.cornerRadius = 16;
        self.chuFaBtn.backgroundColor = Color_ThemeColor;
        [self.chuFaBtn addTarget:self action:@selector(chuFaClick) forControlEvents:UIControlEventTouchUpInside];
        [self.bgView addSubview:self.chuFaBtn];
        
        self.yiChangShangBaoBtn = [UIButton new];
        [self.yiChangShangBaoBtn setTitle:@"状态上报" forState:0];
        [self.yiChangShangBaoBtn setTitleColor:HexColor(0xF35959) forState:0];
        self.yiChangShangBaoBtn.titleLabel.font = BoldFontOfSize(14);
        self.yiChangShangBaoBtn.layer.masksToBounds = YES;
        self.yiChangShangBaoBtn.layer.cornerRadius = 16;
        self.yiChangShangBaoBtn.backgroundColor = HexColorA(0xF35959, 0.1);
        [self.yiChangShangBaoBtn addTarget:self action:@selector(yiChangShangBaoClick) forControlEvents:UIControlEventTouchUpInside];
        [self.bgView addSubview:self.yiChangShangBaoBtn];
        
        self.daoDaBtn = [UIButton new];
        [self.daoDaBtn setTitle:@"到达" forState:0];
        [self.daoDaBtn setTitleColor:HexColor(0xffffff) forState:0];
        self.daoDaBtn.titleLabel.font = BoldFontOfSize(14);
        self.daoDaBtn.layer.masksToBounds = YES;
        self.daoDaBtn.layer.cornerRadius = 16;
        self.daoDaBtn.backgroundColor = Color_ThemeColor;
        [self.daoDaBtn addTarget:self action:@selector(daoDaClick) forControlEvents:UIControlEventTouchUpInside];
        [self.bgView addSubview:self.daoDaBtn];
        
        self.zhuangCheBtn = [UIButton new];
        [self.zhuangCheBtn setTitle:@"装车" forState:0];
        [self.zhuangCheBtn setTitleColor:HexColor(0xffffff) forState:0];
        self.zhuangCheBtn.titleLabel.font = BoldFontOfSize(14);
        self.zhuangCheBtn.layer.masksToBounds = YES;
        self.zhuangCheBtn.layer.cornerRadius = 16;
        self.zhuangCheBtn.backgroundColor = Color_ThemeColor;
        [self.zhuangCheBtn addTarget:self action:@selector(zhuangCheClick) forControlEvents:UIControlEventTouchUpInside];
        [self.bgView addSubview:self.zhuangCheBtn];
        
        self.songHuoChuFaBtn = [UIButton new];
        [self.songHuoChuFaBtn setTitle:@"送货出发" forState:0];
        [self.songHuoChuFaBtn setTitleColor:HexColor(0xffffff) forState:0];
        self.songHuoChuFaBtn.titleLabel.font = BoldFontOfSize(14);
        self.songHuoChuFaBtn.layer.masksToBounds = YES;
        self.songHuoChuFaBtn.layer.cornerRadius = 16;
        self.songHuoChuFaBtn.backgroundColor = Color_ThemeColor;
        [self.songHuoChuFaBtn addTarget:self action:@selector(songHuoChuFaClick) forControlEvents:UIControlEventTouchUpInside];
        [self.bgView addSubview:self.songHuoChuFaBtn];
        
//        self.erWeiMaBtn = [UIButton new];
//        [self.erWeiMaBtn setTitle:@"二维码" forState:0];
//        [self.erWeiMaBtn setTitleColor:HexColor(0x585974) forState:0];
//        self.erWeiMaBtn.titleLabel.font = BoldFontOfSize(14);
//        self.erWeiMaBtn.layer.masksToBounds = YES;
//        self.erWeiMaBtn.layer.cornerRadius = 16;
//        self.erWeiMaBtn.backgroundColor = HexColor(0xffffff);
//        self.erWeiMaBtn.layer.borderColor = HexColor(0xDBDCE6).CGColor;
//        self.erWeiMaBtn.layer.borderWidth = 1;
//        [self.erWeiMaBtn addTarget:self action:@selector(erWeiMaClick) forControlEvents:UIControlEventTouchUpInside];
//        [self.bgView addSubview:self.erWeiMaBtn];
        
        self.guiJiBtn = [UIButton new];
        [self.guiJiBtn setTitle:@"运输轨迹" forState:0];
        [self.guiJiBtn setTitleColor:Color_ThemeColor forState:0];
        self.guiJiBtn.titleLabel.font = BoldFontOfSize(14);
        self.guiJiBtn.layer.masksToBounds = YES;
        self.guiJiBtn.layer.cornerRadius = 16;
        self.guiJiBtn.backgroundColor = HexColor(0xffffff);
        self.guiJiBtn.layer.borderColor = HexColor(0xDBDCE6).CGColor;
        self.guiJiBtn.layer.borderWidth = 1;
        [self.guiJiBtn addTarget:self action:@selector(guiJiClick) forControlEvents:UIControlEventTouchUpInside];
        [self.bgView addSubview:self.guiJiBtn];
        
        self.huiDanFanHuiBtn = [UIButton new];
        [self.huiDanFanHuiBtn setTitle:@"回单返回" forState:0];
        [self.huiDanFanHuiBtn setTitleColor:HexColor(0xffffff) forState:0];
        self.huiDanFanHuiBtn.titleLabel.font = BoldFontOfSize(14);
        self.huiDanFanHuiBtn.layer.masksToBounds = YES;
        self.huiDanFanHuiBtn.layer.cornerRadius = 16;
        self.huiDanFanHuiBtn.backgroundColor = Color_ThemeColor;
        [self.huiDanFanHuiBtn addTarget:self action:@selector(huiDanFanHuiClick) forControlEvents:UIControlEventTouchUpInside];
        [self.bgView addSubview:self.huiDanFanHuiBtn];
        
        self.boHuiReasonBtn = [UIButton new];
        [self.boHuiReasonBtn setTitle:@"驳回原因" forState:0];
        [self.boHuiReasonBtn setTitleColor:HexColor(0xF35959) forState:0];
        self.boHuiReasonBtn.titleLabel.font = BoldFontOfSize(14);
        self.boHuiReasonBtn.layer.masksToBounds = YES;
        self.boHuiReasonBtn.layer.cornerRadius = 16;
        self.boHuiReasonBtn.backgroundColor = HexColorA(0xF35959, 0.1);
        [self.boHuiReasonBtn addTarget:self action:@selector(boHuiReasonClick) forControlEvents:UIControlEventTouchUpInside];
        [self.bgView addSubview:self.boHuiReasonBtn];
    }
    return self;
}

- (void)sureClick {
    if (self.sureBlock) {
        self.sureBlock();
    }
}

- (void)boHuiClick {
    if (self.boHuiBlock) {
        self.boHuiBlock();
    }
}

- (void)diaoDuClick {
    if (self.diaoDuBlock) {
        self.diaoDuBlock();
    }
}

- (void)shouHuoClick {
    if (self.shouHuoBlock) {
        self.shouHuoBlock();
    }
}

- (void)chuFaClick {
    if (self.chuFaBlock) {
        self.chuFaBlock();
    }
}

- (void)yiChangShangBaoClick {
    if (self.YiChangShangBaoBlock) {
        self.YiChangShangBaoBlock();
    }
}

- (void)daoDaClick {
    if (self.daoDaBlock) {
        self.daoDaBlock();
    }
}

- (void)zhuangCheClick {
    if (self.zhuangCheBlock) {
        self.zhuangCheBlock();
    }
}

- (void)songHuoChuFaClick {
    if (self.songHuoChuFaBlock) {
        self.songHuoChuFaBlock();
    }
}

- (void)erWeiMaClick {
    if (self.erWeiMaBlock) {
        self.erWeiMaBlock();
    }
}

- (void)guiJiClick {
    if (self.guiJiBlock) {
        self.guiJiBlock();
    }
}

- (void)huiDanFanHuiClick {
    if (self.huiDanFanHuiBlock) {
        self.huiDanFanHuiBlock();
    }
}

- (void)boHuiReasonClick {
    if (self.boHuiReasonBlock) {
        self.boHuiReasonBlock();
    }
}

-(void)setModel:(TaskManagerListModel *)model {
    _model = model;
    [self configUI];
}

- (void)configUI {
    self.bgView.nim_left = 15;
    self.bgView.nim_top = 0;
    self.bgView.nim_width = ScreenW - 30;
    
    self.noTitleLab.text = @"任务单号：";
    self.noTitleLab.nim_left = 10;
    self.noTitleLab.nim_top = 15;
    [self.noTitleLab sizeToFit];
    
    self.noLab.text = self.model.sta_num;
    self.noLab.nim_left = self.noTitleLab.nim_right;
    [self.noLab sizeToFit];
    self.noLab.nim_centerY = self.noTitleLab.nim_centerY;
    
    self.addressBGView.frame = CGRectMake(10, self.noTitleLab.nim_bottom + 10, self.bgView.nim_width - 20, 105);
    
    self.tiImgView.frame = CGRectMake(10, 15, 22, 22);
    self.tiImgView.image = [UIImage imageNamed:@"icon_add_ti"];
    
    self.songImgView.frame = CGRectMake(10, self.tiImgView.nim_bottom + 30, 22, 22);
    self.songImgView.image = [UIImage imageNamed:@"icon_add_song"];
    
    self.tiAddressLab.text = self.model.s_city;
    [self.tiAddressLab sizeToFit];
    self.tiAddressLab.nim_left = self.tiImgView.nim_right + 15;
    self.tiAddressLab.nim_centerY = self.tiImgView.nim_centerY;
    self.tiAddressLab.nim_width = self.bgView.nim_width - 10 - self.tiAddressLab.nim_left;
    
    self.songAddressLab.text = self.model.r_city;
    [self.songAddressLab sizeToFit];
    self.songAddressLab.nim_left = self.songImgView.nim_right + 15;
    self.songAddressLab.nim_centerY = self.songImgView.nim_centerY;
    self.songAddressLab.nim_width = self.bgView.nim_width - 10 - self.songAddressLab.nim_left;
    
    self.linkLine.nim_centerX = self.tiImgView.nim_centerX;
    self.linkLine.nim_top = self.tiImgView.nim_bottom;
    self.linkLine.nim_width = 2;
    self.linkLine.nim_height = 30;
    
    self.marginLine1.nim_left = self.tiAddressLab.nim_left;
    self.marginLine1.nim_centerY = self.addressBGView.nim_height * 0.5;
    self.marginLine1.nim_width = self.addressBGView.nim_width - self.marginLine1.nim_left;
    self.marginLine1.nim_height = 1;
    
    self.taskTitleLab.text = @"任务来源：";
    [self.taskTitleLab sizeToFit];
    self.taskTitleLab.nim_left = self.addressBGView.nim_left;
    self.taskTitleLab.nim_top = self.addressBGView.nim_bottom + 10;
    
    self.taskLab.text = self.model.t_name;
    [self.taskLab sizeToFit];
    self.taskLab.nim_left = self.taskTitleLab.nim_right;
    self.taskLab.nim_centerY = self.taskTitleLab.nim_centerY;
    self.taskLab.nim_width = self.bgView.nim_width - 10 - self.taskLab.nim_left;
    
    self.carTitleLab.text = @"车辆要求：";
    [self.carTitleLab sizeToFit];
    self.carTitleLab.nim_left = self.addressBGView.nim_left;
    self.carTitleLab.nim_top = self.taskTitleLab.nim_bottom + 5;
    
    self.carLab.text = self.model.car_require;
    [self.carLab sizeToFit];
    self.carLab.nim_left = self.carTitleLab.nim_right;
    self.carLab.nim_centerY = self.carTitleLab.nim_centerY;
    self.carLab.nim_width = self.bgView.nim_width - 10 - self.carLab.nim_left;
    
    self.jnumTitleLab.text = @"件数：";
    [self.jnumTitleLab sizeToFit];
    self.jnumTitleLab.nim_left = self.addressBGView.nim_left;
    self.jnumTitleLab.nim_top = self.carTitleLab.nim_bottom + 5;
    
    self.jnumLab.text = [NSString stringWithFormat:@"%@件",self.model.all_pnum];
    [self.jnumLab sizeToFit];
    self.jnumLab.nim_left = self.jnumTitleLab.nim_right;
    self.jnumLab.nim_centerY = self.jnumTitleLab.nim_centerY;
    self.jnumLab.nim_width = self.bgView.nim_width * 0.5 - self.jnumLab.nim_left;
    
    self.countTitleLab.text = @"数量：";
    [self.countTitleLab sizeToFit];
    self.countTitleLab.nim_left = self.bgView.nim_width * 0.5;
    self.countTitleLab.nim_centerY = self.jnumTitleLab.nim_centerY;
    
    self.countLab.text = [NSString stringWithFormat:@"%@",self.model.all_num];
    [self.countLab sizeToFit];
    self.countLab.nim_left = self.countTitleLab.nim_right;
    self.countLab.nim_centerY = self.countTitleLab.nim_centerY;
    self.countLab.nim_width = self.bgView.nim_width - 10 - self.countLab.nim_left;
    
    self.weightTitleLab.text = @"重量：";
    [self.weightTitleLab sizeToFit];
    self.weightTitleLab.nim_left = self.addressBGView.nim_left;
    self.weightTitleLab.nim_top = self.jnumTitleLab.nim_bottom + 5;
    
    self.weightLab.text = [self.model.all_weight floatValue] ? [NSString stringWithFormat:@"%@KG",self.model.all_weight] : @"--KG";
    [self.weightLab sizeToFit];
    self.weightLab.nim_left = self.weightTitleLab.nim_right;
    self.weightLab.nim_centerY = self.weightTitleLab.nim_centerY;
    self.weightLab.nim_width = self.bgView.nim_width * 0.5 - self.weightLab.nim_left;
    
    self.volumeTitleLab.text = @"体积：";
    [self.volumeTitleLab sizeToFit];
    self.volumeTitleLab.nim_left = self.bgView.nim_width * 0.5;
    self.volumeTitleLab.nim_centerY = self.weightTitleLab.nim_centerY;
    
    self.volumeLab.text = [self.model.all_volume floatValue] ? [NSString stringWithFormat:@"%@m³",self.model.all_volume] : @"--m³";
    [self.volumeLab sizeToFit];
    self.volumeLab.nim_left = self.volumeTitleLab.nim_right;
    self.volumeLab.nim_centerY = self.volumeTitleLab.nim_centerY;
    self.volumeLab.nim_width = self.bgView.nim_width - 10 - self.volumeLab.nim_left;
    
    self.timeTitleLab.text = @"发布时间：";
    [self.timeTitleLab sizeToFit];
    self.timeTitleLab.nim_left = self.addressBGView.nim_left;
    self.timeTitleLab.nim_top = self.weightTitleLab.nim_bottom + 5;
    
    self.timeLab.text = [NSString stringWithFormat:@"%@",self.model.create_time];
    [self.timeLab sizeToFit];
    self.timeLab.nim_left = self.timeTitleLab.nim_right;
    self.timeLab.nim_centerY = self.timeTitleLab.nim_centerY;
    self.timeLab.nim_width = self.bgView.nim_width - 10 - self.timeLab.nim_left;
    
    if (self.model.is_fa == 1) {
        self.price1TitleLab.text = @"报价";
        [self.price1TitleLab sizeToFit];
        self.price1Lab.text = self.model.price.length ? ([self.model.price floatValue] ? self.model.price : @"--") : @"--";
        [self.price1Lab sizeToFit];
        self.price1UnitLab.text = @"元";
        [self.price1UnitLab sizeToFit];
        
        self.price1TitleLab.nim_left = self.addressBGView.nim_left;
        self.price1TitleLab.nim_top = self.timeTitleLab.nim_bottom + 15;
        self.price1Lab.nim_left = self.price1TitleLab.nim_right + 10;
        self.price1Lab.nim_centerY = self.price1TitleLab.nim_centerY;
        self.price1UnitLab.nim_left = self.price1Lab.nim_right + 5;
        self.price1UnitLab.nim_centerY = self.price1Lab.nim_centerY;
        
        self.descLab.text = @"如有合同价格按实际合同价格计算!";
        [self.descLab sizeToFit];
        self.descLab.nim_left = self.addressBGView.nim_left;
        self.descLab.nim_top = self.price1TitleLab.nim_bottom + 5;
        
        self.bgView.nim_height = self.descLab.nim_bottom + 60;
        self.height = self.bgView.nim_bottom;
    }else {
        self.price1TitleLab.frame = CGRectZero;
        self.price1Lab.frame = CGRectZero;
        self.price1UnitLab.frame = CGRectZero;
        
        self.descLab.frame = CGRectZero;
        
        self.bgView.nim_height = self.timeTitleLab.nim_bottom + 60;
        self.height = self.bgView.nim_bottom;
    }
    
    self.boHuiBtn.frame = CGRectZero;
    self.sureBtn.frame = CGRectZero;
    self.diaoDuBtn.frame = CGRectZero;
    self.shouHuoBtn.frame = CGRectZero;
    self.chuFaBtn.frame = CGRectZero;
    self.yiChangShangBaoBtn.frame = CGRectZero;
    self.daoDaBtn.frame = CGRectZero;
    self.zhuangCheBtn.frame = CGRectZero;
    self.songHuoChuFaBtn.frame = CGRectZero;
    self.erWeiMaBtn.frame = CGRectZero;
    self.guiJiBtn.frame = CGRectZero;
    self.huiDanFanHuiBtn.frame = CGRectZero;
    self.boHuiReasonBtn.frame = CGRectZero;
    
    NSString *statusStr = @"";
    if ([self.model.status isEqualToString:@"1"]) {
        statusStr = @"新建";
        self.sureBtn.frame = CGRectMake(self.bgView.nim_width - 20 - 60, self.height - 15 - 32, 60, 32);
        self.boHuiBtn.frame = CGRectMake(self.sureBtn.nim_left - 10 - 60, self.height - 15 - 32, 60, 32);
    }else if ([self.model.status isEqualToString:@"2"]) {
        statusStr = @"受理";
        if (self.model.is_sta_type == 1) {
            //多车 显示调度和收货
            if (self.model.is_stick != 1) {
                //第一棒 不显示收货 其余显示
                if (self.model.is_receie == 1) {
                    //收货未完成
                    self.shouHuoBtn.frame = CGRectMake(self.bgView.nim_width - 20 - 60, self.height - 15 - 32, 60, 32);
                }
            }
            if (self.model.is_all_num == 1) {
                //未调度完成 显示调度
                if (self.model.is_receie == 2) {
                    self.diaoDuBtn.frame = CGRectMake(self.shouHuoBtn.nim_width ? self.shouHuoBtn.nim_left - 10 - 60 : self.bgView.nim_width - 20 - 60, self.height - 15 - 32, 60, 32);
                }
            }
        }else {
            //单车 显示出发
            if (self.model.is_stick != 1) {
                //第一棒 不显示收货 其余显示
                if (self.model.is_receie == 1) {
                    //收货未完成
                    self.shouHuoBtn.frame = CGRectMake(self.bgView.nim_width - 20 - 60, self.height - 15 - 32, 60, 32);
                }
            }
            self.chuFaBtn.frame = CGRectMake(self.shouHuoBtn.nim_width ? self.shouHuoBtn.nim_left - 10 - 60 : self.bgView.nim_width - 20 - 60, self.height - 15 - 32, 60, 32);
        }
        if (self.model.is_plan == 2) {
            //是计划
            self.shouHuoBtn.frame = CGRectZero;
            self.diaoDuBtn.frame = CGRectZero;
            self.chuFaBtn.frame = CGRectZero;
        }
    }else if ([self.model.status isEqualToString:@"3"]) {
        if (self.model.is_sta_type != 1) {
            self.boHuiReasonBtn.frame = CGRectMake(10, self.height - 15 - 32, 88, 32);
        }else {
            self.boHuiReasonBtn.frame = CGRectMake(10, self.height - 15 - 32, 88, 32);
            if (self.model.type == 1) {
                statusStr = @"我方驳回";
            }else if (self.model.type == 2) {
                statusStr = @"司机驳回";
            }
        }
    }else if ([self.model.status isEqualToString:@"4"]) {
        statusStr = @"提货出发";
        if (self.model.is_sta_type != 1) {
            //单车
            self.daoDaBtn.frame = CGRectMake(self.bgView.nim_width - 20 - 60, self.height - 15 - 32, 60, 32);
            self.yiChangShangBaoBtn.frame = CGRectMake(self.daoDaBtn.nim_left - 10 - 88, self.height - 15 - 32, 88, 32);
        }else {
            //多车
            self.guiJiBtn.frame = CGRectMake(self.bgView.nim_width - 20 - 88, self.height - 15 - 32, 88, 32);
        }
    }else if ([self.model.status isEqualToString:@"5"]) {
        statusStr = @"提货到达";
        if (self.model.is_sta_type != 1) {
            if (self.model.is_loading == 1) {
                //装车未完成 显示 装车、异常上报
                self.zhuangCheBtn.frame = CGRectMake(self.bgView.nim_width - 20 - 60, self.height - 15 - 32, 60, 32);
                self.yiChangShangBaoBtn.frame = CGRectMake(self.zhuangCheBtn.nim_left - 10 - 88, self.height - 15 - 32, 88, 32);
            }else {
                //装车完成 显示送货出发、异常上报
                self.songHuoChuFaBtn.frame = CGRectMake(self.bgView.nim_width - 20 - 88, self.height - 15 - 32, 88, 32);
                self.yiChangShangBaoBtn.frame = CGRectMake(self.songHuoChuFaBtn.nim_left - 10 - 88, self.height - 15 - 32, 88, 32);
            }
        }else {
            self.guiJiBtn.frame = CGRectMake(self.bgView.nim_width - 20 - 88, self.height - 15 - 32, 88, 32);
        }
    }else if ([self.model.status isEqualToString:@"6"]) {
        statusStr = @"送货出发";
        if (self.model.is_sta_type != 1) {
            self.daoDaBtn.frame = CGRectMake(self.bgView.nim_width - 20 - 60, self.height - 15 - 32, 60, 32);
            self.yiChangShangBaoBtn.frame = CGRectMake(self.daoDaBtn.nim_left - 10 - 88, self.height - 15 - 32, 88, 32);
        }else {
            self.guiJiBtn.frame = CGRectMake(self.bgView.nim_width - 20 - 88, self.height - 15 - 32, 88, 32);
        }
    }else if ([self.model.status isEqualToString:@"7"]) {
        statusStr = @"送货到达";
        if (self.model.is_sta_type != 1) {
//            self.erWeiMaBtn.frame = CGRectMake(self.bgView.nim_width - 20 - 74, self.height - 15 - 32, 74, 32);
            self.yiChangShangBaoBtn.frame = CGRectMake(self.bgView.nim_width - 20 - 88, self.height - 15 - 32, 88, 32);
        }else {
            self.guiJiBtn.frame = CGRectMake(self.bgView.nim_width - 20 - 88, self.height - 15 - 32, 88, 32);
        }
    }else if ([self.model.status isEqualToString:@"8"]) {
        statusStr = @"签收";
        if (self.model.is_sta_type != 1) {
            if (self.model.p_sta_id == 0) {
                self.huiDanFanHuiBtn.frame = CGRectMake(self.bgView.nim_width - 20 - 88, self.height - 15 - 32, 88, 32);
            }
        }else {
            if (self.model.p_sta_id == 0) {
                self.huiDanFanHuiBtn.frame = CGRectMake(self.bgView.nim_width - 20 - 88, self.height - 15 - 32, 88, 32);
                self.guiJiBtn.frame = CGRectMake(self.huiDanFanHuiBtn.nim_left - 10 - 88, self.height - 15 - 32, 88, 32);
            }else {
                self.guiJiBtn.frame = CGRectMake(self.bgView.nim_width - 20 - 88, self.height - 15 - 32, 88, 32);
            }
        }
    }else {
        self.guiJiBtn.frame = CGRectMake(self.bgView.nim_width - 20 - 88, self.height - 15 - 32, 88, 32);
    }
    self.laiYuanLab.text = statusStr;
    [self.laiYuanLab sizeToFit];
    self.laiYuanLab.nim_left = self.bgView.nim_width - 10 - self.laiYuanLab.nim_width;
    self.laiYuanLab.nim_centerY = self.noLab.nim_centerY;
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
